<%@ include file="/common/taglibs.jsp"%>
<script type="text/javascript">
	function setMetricUnitLabel(metricUnitValue){
		if(metricUnitValue){
			$("metricUnitLabel2").innerHTML=$("metricUnitLabel1").innerHTML=metricUnitValue;
		}
	}
	function metricUnitChange(){
		for(i=0,o=document.forms["shippingRateForm"].elements["metricUnitCode"];i<o.options.length;i++){
			if(o.options[i].selected) setMetricUnitLabel(o.options[i].text);
		}
	}
	metricUnitChange();
	
	//地区选择器回调函数
	function regionSeclectCallback(region){
		$j('#regionId').val(region.id);
		$j('#regionName').html(region.fullName);
		closeDialogOfregionSelector();
		validateField($('regionId'),"required");
	}
	//自定义地区选择器回调函数
	function userDefinedRegionSeclectCallback(region){
		$j('#regionId').val(region.id);
		$j('#regionName').html(region.name);
		closeDialogOfuserDefinedRegionSelector();
		validateField($('regionId'),"required");
	}
	
</script>
<div class="top clearfix">
	<ul class="tab">
		<li class="curr">
			<span><fmt:message key="shippingRateDetail.edit.title" /> </span>
		</li>
	</ul>
</div>
<div class="modify">
	<form class="mainForm" method="post" target="_parent"
		action="<c:url value="/system/editShippingRateBean/dialog.html"/>" id="shippingRateForm">
		<spring:bind path="shippingRate.version">
			<input type="hidden" name="version" value="<c:out value="${status.value}"/>" />
		</spring:bind>
		<spring:bind path="shippingRate.shippingRateId">
			<input type="hidden" name="shippingRateId" value="<c:out value="${status.value}"/>" />
		</spring:bind>
		<spring:bind path="shippingRate.baseOn">
			<input type="hidden" name="${status.expression}" value="0" />
		</spring:bind>
		<table class="com_modi_table" width="100%" border="0" cellspacing="0" cellpadding="0">
			<tr>
				<th width="25%">
					<StoreAdmin:label key="shippingRate.shippingMethodId" />
				</th>
				<td>
					<input type="hidden" name="shippingMethodId" id="shippingMethodId"
						value="${shippingRate.shippingMethod.shippingMethodId}" />
						${shippingRate.shippingMethod.shippingMethodName} 
				</td>
			</tr>
			<tr>
				<th width="25%">
					<StoreAdmin:label styleClass="required" key="shippingRate.regionId" />
				</th>
				<td>
					<spring:bind path="shippingRate.regionId">
						<span> <input type="hidden" name="<c:out value="${status.expression}"/>"
								id="<c:out value="${status.expression}"/>" value="<c:out value="${status.value}"/>" /> 
								<span class="fieldError"><c:out value="${status.errorMessage}" />
						</span> </span>
						<b><span id="regionName"><c:if test="${not empty shippingRate.region.fullName}">${shippingRate.region.fullName}</c:if></span></b>	
						
						<fmt:message key="shippingRateForm.pleaseSelect" />	
						<input class="btn3" type="button" value="<fmt:message key="shippingRateForm.selectNormalRegion"/>"
							onclick="showDialogOfregionSelector()">
						<fmt:message key="shippingRateForm.regionOr" />
						<input  class="btn3"  type="button" value="<fmt:message key="shippingRateForm.selectUserDefinedRegion"/>"
							onclick="showDialogOfuserDefinedRegionSelector()">
						<span style="display: none"> <system:regionSelector selectorId="regionSelector"
								callbackFunc="regionSeclectCallback" /> <system:userDefinedRegionSelector
								selectorId="userDefinedRegionSelector" callbackFunc="userDefinedRegionSeclectCallback" /> </span>


					</spring:bind>
				</td>
			</tr>
			<tr>
				<th>
					<StoreAdmin:label key="shippingRate.metricUnitCode" />
				</th>
				<td>
					<select name="metricUnitCode" onchange="metricUnitChange();" style="width: 80px"
						class="selecttxt">
						<option value="g" <c:if test="${shippingRate.metricUnitCode eq 'g'}">selected="true"</c:if>>
							<fmt:message key="shippingRate.g" />
						</option>
						<option value="kg" <c:if test="${shippingRate.metricUnitCode eq 'kg'}">selected="true"</c:if>>
							<fmt:message key="shippingRate.kg" />
						</option>
					</select>

				</td>
			</tr>
			<tr>
				<th>
					<StoreAdmin:label key="shippingRate.baseWeight" />
				</th>
				<td>
					<span> <spring:bind path="shippingRate.basePrice">
							<input type="text" maxlength="8" size="6" name="<c:out value="${status.expression}"/>"
								id="${status.expression}" value="${shippingRate.basePrice}" class="inputtxt" />
							<fmt:message key="shippingRate.currency" />
							<span class="fieldError"><c:out value="${status.errorMessage}" /> </span>
						</spring:bind> </span> &nbsp;/&nbsp;
					<span> <spring:bind path="shippingRate.baseWeight">
							<input type="text" maxlength="9" size="5" name="<c:out value="${status.expression}"/>"
								id="${status.expression}" value="${shippingRate.baseWeight}" class="inputtxt" />
							<span id="metricUnitLabel1"></span>
						</spring:bind> </span>
					<fmt:message key="shippingRate.baseWeightTip" />
				</td>
			</tr>
			<tr>
				<th>
					<StoreAdmin:label key="shippingRate.overWeight" />
				</th>
				<td>
					<span> <spring:bind path="shippingRate.weightPerRate">
							<input type="text" maxlength="9" size="6" name="<c:out value="${status.expression}"/>"
								id="${status.expression}" value="${shippingRate.weightPerRate}" class="inputtxt" />
							<fmt:message key="shippingRate.currency" />
							<span class="fieldError"><c:out value="${status.errorMessage}" /> </span>
						</spring:bind> </span> &nbsp;/&nbsp;
					<span> <spring:bind path="shippingRate.increaseUnit">
							<input type="text" maxlength="9" size="5" name="<c:out value="${status.expression}"/>"
								id="${status.expression}" value="${shippingRate.increaseUnit}" class="inputtxt" />
							<span id="metricUnitLabel2"></span>
						</spring:bind> </span>
					<fmt:message key="shippingRate.overWeightTip" />
				</td>
			</tr>
			<tr>
				<th>
					<StoreAdmin:label key="shippingRate.description" />
				</th>
				<td>
					<spring:bind path="shippingRate.description">
						<textarea name="${status.expression}" id="${status.expression}" class="textareatxt" rows="3"
							cols="60">${status.value}</textarea>
						<span class="fieldError">${status.errorMessage}</span>
					</spring:bind>
				</td>
			</tr>
			<tr>
				<td colspan="2">
					<fmt:message key="shippingRate.formula" />
				</th>
			</tr>
		</table>
	</form>
</div>


<v:javascript formName="shippingRate" staticJavascript="false" />
